/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef APP_KVSTORE_CONFLICT_DATA_IMPL_H
#define APP_KVSTORE_CONFLICT_DATA_IMPL_H

#include "app_kvstore_conflict_data.h"
#include "app_types.h"
#include "kv_store_nb_conflict_data.h"

namespace OHOS {
namespace AppDistributedKv {
struct KvStoreConflictData {
    Value value {};
    bool isDeleted = false;
    bool isLocal = false;
    Status status {};
};

struct KvStoreConflictEntry {
    int type = 1;
    Key key {};
    KvStoreConflictData oldData {};
    KvStoreConflictData newData {};
};

class AppKvStoreConflictDataImpl final : public AppKvStoreConflictData {
public:
    explicit AppKvStoreConflictDataImpl(const KvStoreConflictEntry &kvStoreConflictEntry);

    ~AppKvStoreConflictDataImpl();

    AppKvStoreConflictPolicyType GetType() const override;

    void GetKey(Key &key) const override;

    Status GetValue(ConflictValueType type, Value &value) const override;

    bool IsDeleted(ConflictValueType type) const override;

    bool IsNative(ConflictValueType type) const override;

private:
    const KvStoreConflictEntry kvStoreConflictEntry_;
};
}  // namespace AppDistributedKv
}  // namespace OHOS

#endif  // APP_KVSTORE_CONFLICT_DATA_IMPL_H
